<%@include file="../../../base/include.jsp"%>
<%@include file="../../modal/preview.jsp"%>

<div class="page-header">
	<h3>Editing user "${userCommand.mail}"</h3>
</div>

<div>
	<form:form class="form-stacked" commandName="userCommand">
		<form:hidden path="id" />
		<form:hidden path="mail" />
		<form:hidden path="token" />
		<div class="clearfix">
			<label>Registration date/time: ${userCommand.dateRegistred}</label>
		</div>
		<div class="clearfix">
			<form:checkbox class="user-form-input" path="enabled"
				value="${enabled}" />
			Enabled
		</div>
		<div class="clearfix">
			<label>Full Name:</label>
			<form:input class="user-form-input" path="name" value="${name}" />
		</div>
		<div class="clearfix" id="password-div">
			<button class="btn btn-small" type="button" onclick="smthChanged = true;showPasswordInput()">Change
				password</button>
		</div>


		<div>
			<div class="page-header">
				<h4>Groups, user participates in:</h4>
			</div>

			<div id="userGroupsDiv"> 
				<button id="btnArticleGroupAdd" type="button" class="btn btn-small" onclick="smthChanged = true;showGroupModalList('userGroups')">Add</button>
				<button id="btnArticleGroupRemove" type="button" class="btn btn-small" onclick="smthChanged = true;groupRemoveFromList()">Remove</button>
				<br/>
				<br/>
				<div style="display: table;">
					<c:forEach var="group" items="${userCommand.groups}"
							varStatus="iterator">
						
						<div style="display: table-row;">
							<form:hidden path="groups[${iterator.index}].id"/>
							<form:hidden path="groups[${iterator.index}].name"/>
						  	<div style="display: table-cell;">
						  		<input id="groups_selected_${group.id}" type="checkbox">
						  	</div>
						  	<div style="display: table-cell; padding-left: 5px;">
						  		<a href="<c:url value='/admin/group/${group.id}'/>">${group.name}</a>
						  	</div>
						</div>
						
					</c:forEach>
				</div>
			</div>

		</div>
	</form:form>
</div>

<script type="text/javascript">
	setActiveMainMenuElem('administration');
	$('#menuAllUsers').addClass('active');
	safetyLeave();
</script>

